package com.cdzt.hqse.controller;

import com.cdzt.hqse.entity.Hero;
import com.cdzt.hqse.service.HeroService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**
 * @author: heroC
 * @time: 2020/10/5 11:37
 * 处理前端请求
 */
@Controller
public class HeroController {

    @Autowired
    private HeroService heroService;

    /**
     * 处理test请求，查询所有记录
     * @param model
     * @return
     */
    @GetMapping(value = "/test")
    public String testInfo(Model model){
        List<Hero> heroInfo = heroService.getTestInfo();
        model.addAttribute("heroInfos", heroInfo);
        return "test";
    }
}
